﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace ParserGenerator.ParserConstruction
{
    [Serializable]
    public sealed class ParserAutomatonStateGroup : ReadOnlyCollection<ParserAutomatonState>
    {
        public int Number => LR0Isocore.Number;
        public ParserAutomatonState LR0Isocore => Items[0];

        internal ParserAutomatonStateGroup(ParserAutomatonState lr0Isocore)
            : base(new List<ParserAutomatonState>())
        {
            if (lr0Isocore == null)
                throw new ArgumentNullException(nameof(lr0Isocore));
            Items.Add(lr0Isocore);
        }

        internal void Add(ParserAutomatonState isocore)
        {
            if (isocore == null)
                throw new ArgumentNullException(nameof(isocore));
            Items.Add(isocore);
        }

        public sealed override string ToString()
        {
            return "[" + string.Join(", ", Items) + "]";
        }
    }
}
